﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>IOBft Wallet</title>

    <!-- Bootstrap -->
    <link href="bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="js/mystyle.css" type="text/css" rel="stylesheet">

    <!--自定义样式
    <!--<style>
        .jumbotron {
            background: url(images/model.png);
        }
    </style>
     -->

</head>
<body>
    <script src="bootstrap/jquery.min.js"></script>
    <script src="bootstrap/bootstrap.min.js"></script>
    <!--<script type="text/javascript" src="js/crypto/encrypt/base/basex.js"></script>
    <script type="text/javascript" src="js/crypto/encrypt/base/base58.js"></script>
    <script type="text/javascript" src="js/crypto/encrypt/ed25519/nacl-fast.js"></script>
    <script type="text/javascript" src="js/crypto/utils/encrpt-ed25519.js"></script>-->

    <script type="text/javascript" src="crypto-master/js/encrypt/base/basex.js"></script>
    <script type="text/javascript" src="crypto-master/js/encrypt/base/base58.js"></script>
    <script type="text/javascript" src="crypto-master/js/encrypt/ed25519/nacl-fast.js"></script>
    <script type="text/javascript" src="crypto-master/js/utils/encrypt-ed25519-2.js"></script>

    <script type="text/javascript" src="js/crypto-js.js"></script>
    <script src='js/forge-sha256.min.js'></script>
    <script src='js/hashes.js'></script>
    <script src='js/wallet.js'></script>
    <script src='js/helper.js'></script>
    <script src='js/Login.js'></script>

    <div class="container">

        <div class="jumbotron">
            <h1>IOBft</h1>
            <button type="button" class="btn btn-primary" onclick='OnRefresh()'>刷新</button>
            <button type="button" class="btn btn-success" onclick='OnConsole()'>console</button>
        </div>

        <div style="width:100%;height:100%;overflow-x:auto;">
            <table class="table table-hover" id="myrules">
                <caption>Rules:</caption>
                <thead>
                    <tr>
                        <th>Address</th>
                        <th>Start</th>
                        <th>End</th>
                    </tr>
                </thead>
            </table>
        </div>

        <div style="width:100%;height:100%;overflow-x:auto;">
            <table class="table table-hover" id="mynode">
                <caption>Node:</caption>
                <thead>
                    <tr>
                        <th>nodeId</th>
                        <th>address</th>
                        <th>ipEndPoint</th>
                        <th>kIndex</th>
                        <th>time</th>
                    </tr>
                </thead>
            </table>
        </div>

    </div>

    <footer class="navbar-fixed-bottom navbar-inverse">
        <div class="row nav_box">
            <div class="qx_1"><a href="index.html"><h3 class="text-primary">钱包</h3></a></div>
            <div class="qx_1"><a href="browser.html"><h3 class="text-success">区块</h3></a></div>
            <div class="qx_1"><a href="rules.html"><h3 class="text-danger">节点</h3></a></div>
            <div class="qx_1"><a href="setting.html"><h3 class="text-warning">设置</h3></a></div>
        </div>
    </footer>

    <script>
        function liOnclick(e) {
            //alert(e.id);
        };
        function OnRefresh(e) {
            window.location.href = window.location.href;
        };
        function OnConsole(e) {
            window.location.href = "console.html";
        };

        var colorlist = ["list-group-item-success", "", "list-group-item-info", "", "list-group-item-warning", "", "list-group-item-danger", ""];
        var colorindex = 0;
        var platform = Helper.checkPlatform();

        $.ajax({
            url: Helper.GetServerIP() + "/Rules",
            dataType: "text",
            type: "get",
            data: { get: "all" },
            success: function (data) {

                var jsonObj = JSON.parse(data);
                for (var key in jsonObj) {

                    var color = colorlist[colorindex % colorlist.length]; colorindex++;
                    Helper.TableInsert("myrules", jsonObj[key]["Address"], color,
                        Helper.Simplify(jsonObj[key]["Address"], platform),
                        jsonObj[key]["Start"],
                        jsonObj[key]["End"]);
                }


            },
            error: function (err) {
                //alert("提交失败");
            }
        });

        $.ajax({
            url: Helper.GetServerIP() + "/Node",
            dataType: "text",
            type: "get",
            data: { get: "all" },
            success: function (data) {

                var jsonObj = JSON.parse(data);
                for (var key in jsonObj) {
                    var color = colorlist[colorindex % colorlist.length]; colorindex++;
                    Helper.TableInsert("mynode", jsonObj[key]["address"]+1, color,
                        jsonObj[key]["nodeId"],
                        Helper.Simplify(jsonObj[key]["address"], platform),
                        jsonObj[key]["ipEndPoint"],
                        jsonObj[key]["kIndex"],
                        jsonObj[key]["time"]);
                }


            },
            error: function (err) {
                //alert("提交失败");
            }
        });



    </script>

</body>
</html>